//
// Created by francklinson on 2021/7/15 AT 0:11.
//
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

class Solution {
public:
    int maximumElementAfterDecrementingAndRearranging(vector<int> &arr) {
        sort(arr.begin(), arr.end());
        arr.front() = 1;
        for (int i = 1; i < arr.size(); ++i) {
            if (arr[i] > arr[i - 1])
                arr[i] = arr[i - 1] + 1;
        }
        return arr.back();
    }
};

int main() {
    vector<int> arr{73,98,9};
    Solution solution;
    cout << solution.maximumElementAfterDecrementingAndRearranging(arr) << endl;
    return 0;
}

